﻿using System.Threading.Tasks;
using Magicodes.ExporterAndImporter.Excel.AspNetCore;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NP.BPMReportPlatform.HSE.Dto;
using Volo.Abp.Application.Dtos;

namespace NP.BPMReportPlatform.HSE
{
    /// <summary>
    /// HSE类 接口
    /// </summary>
    [Authorize]
    [ApiController]
    [Route("api/HSE")]
    public class HSEController : BPMReportPlatformController
    {
        private readonly IHSEService _hseService;

        public HSEController(IHSEService hseService)
        {
            _hseService = hseService;
        }

        /// <summary>
        ///HSE信息系统配置和数据变更审批流程 查询数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("HSEDataChange/GetAllAsync")]
        public async Task<PagedResultDto<GetHSEDataChangeOutput>> GetAllAsync([FromBody] GetHSEInput input)
        {
            return await _hseService.GetAllAsync(input);
        }

        /// <summary>
        /// HSE信息系统配置和数据变更审批流程  导出数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("HSEDataChange/ExportAsync")]
        public async Task<XlsxFileResult<GetHSEDataChangeOutput>> ExportAsync([FromBody] GetHSEInput input)
        {
            var rst = await _hseService.ExportAsync(input);
            return new XlsxFileResult<GetHSEDataChangeOutput>(rst, "导出Excel");
        }
    }
}